par(mfrow=c(1,2))
plot(educ,colMeans(Yhat), col="blue", type = "l",
lwd=3, bty="n", ylab="Estimated Effect of Exposure",
xlab="Share of People with Tertiary Education")
points(educ,Y.3[,1], type="l", lty=3,
col="blue", lwd=2)
points(educ,Y.3[,3], type="l", lty=3,
col="blue", lwd=2)
for (i in 1:5000){
points(educ,Yhat[i,], type="l",
col=rgb(0,0,255,2,maxColorValue = 255), lwd=2)
}
# 2nd plot
plot(timeL,colMeans(Yhatt), col="blue", type = "l",
lwd=3, bty="n", ylab="Estimated Effect of Exposure",
xlab="Months since Exposure")
points(timeL,Y.7[,1], type="l", lty=3,
col="blue", lwd=2)
points(timeL,Y.7[,3], type="l", lty=3,
col="blue", lwd=2)
for (i in 1:5000){
points(timeL,Yhatt[i,], type="l",
col=rgb(0,0,255,2,maxColorValue = 255), lwd=2)
}
dev.off()
install.packages(c("gpclib", "raster", "rgdal"))
library(rgdal)
library(dplyr)
library(ggplot2)
library(raster)
library("gpclib")
getwd()
gde_15 <- readOGR( layer = "gde-1-1-15")
#read in geodata ----
gde_15 <- readOGR("geodata/", layer = "gde-1-1-15")
crs(gde_15) <- "+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs"
gde_15l <- readOGR(dsn="geodata", layer="VEC200_HOHEITSGEBIET_LV95")
gde_15l <- spTransform(gde_15l, CRS("+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs"))
ch <- gde_15l[gde_15l@data$ICC=="CH", ]
ch_geom <- fortify(ch, region="ICC")
seen_geom <- readRDS("geodata/seen_geom.Rds")
ch_geom <- readRDS("geodata/ch_geom.Rds")
quakes <- foreign::read.dta("data/Disaster_events_dates_keeperL.dta")%>%
dplyr::select(J, K, keeperL)%>%
rename(long=J, lat=K)
quakes <- foreign::read.dta("geodata/Disaster_events_dates_keeperL.dta")%>%
dplyr::select(J, K, keeperL)%>%
rename(long=J, lat=K)
quakes0 <- quakes[quakes$keeperL==0,1:2]
quakes1 <- quakes[quakes$keeperL==1,1:2]
map_data <- readRDS("data/map_data.Rds")
map_data <- readRDS("geodata/map_data.Rds")
relief <- raster("geodata/02-relief-georef-clipped-resampled.tif")
relief_spdf <- as(relief, "SpatialPixelsDataFrame")
relief <- as.data.frame(relief_spdf) %>%
rename(value = `X02.relief.georef.clipped.resampled`)
##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A##A
#plot ----
colls <- c("violetred4", "firebrick", "firebrick4", "violetred", "darkred", "darkmagenta", "darkorchid4", "blueviolet", "deeppink1")
col0 <- "white"
col1 <- "firebrick"
i <- 1
#for(i in colls){
ggplot()+
geom_raster(data = relief, aes(x = x, y = y, alpha=value/100))+
geom_polygon(data = map_data, aes(x=long, y=lat, group=group), fill="white")+
geom_path(data = ch_geom, aes(x=long, y=lat, group=group),color="grey80", size=.3)+
geom_polygon(data=seen_geom, aes(x=long, y=lat, group=group), fill="lightblue")+
geom_path(data=seen_geom, aes(x=long, y=lat, group=group), color="grey80", size=.3)+
geom_point(data=quakes0, aes(x=long, y=lat), color=col0, alpha=.5, size=0.4, pch=4)+
geom_point(data=quakes1, aes(x=long, y=lat), color=col1, alpha=.8, size=0.8)+
coord_equal()+
guides(alpha=FALSE)+
theme_bw()+
labs(y="", x="")+
theme(axis.text=element_blank(),
axis.ticks = element_blank(),
panel.grid = element_line(size=.2))+
colls <- c("violetred4", "firebrick", "firebrick4", "violetred", "darkred", "darkmagenta", "darkorchid4", "blueviolet", "deeppink1")
col0 <- "white"
col1 <- "firebrick"
i <- 1
#for(i in colls){
ggplot()+
geom_raster(data = relief, aes(x = x, y = y, alpha=value/100))+
geom_polygon(data = map_data, aes(x=long, y=lat, group=group), fill="white")+
geom_path(data = ch_geom, aes(x=long, y=lat, group=group),color="grey80", size=.3)+
geom_polygon(data=seen_geom, aes(x=long, y=lat, group=group), fill="lightblue")+
geom_path(data=seen_geom, aes(x=long, y=lat, group=group), color="grey80", size=.3)+
geom_point(data=quakes0, aes(x=long, y=lat), color=col0, alpha=.5, size=0.4, pch=4)+
geom_point(data=quakes1, aes(x=long, y=lat), color=col1, alpha=.8, size=0.8)+
coord_equal()+
guides(alpha=FALSE)+
theme_bw()+
labs(y="", x="")+
theme(axis.text=element_blank(),
axis.ticks = element_blank(),
panel.grid = element_line(size=.2))+
ggsave(filename=paste0("relief_map_", i, ".pdf"), height=6, width=9.708)
#}
colls <- c("violetred4", "firebrick", "firebrick4", "violetred", "darkred", "darkmagenta", "darkorchid4", "blueviolet", "deeppink1")
col0 <- "white"
col1 <- "firebrick"
i <- 1
#for(i in colls){
ggplot()+
geom_raster(data = relief, aes(x = x, y = y, alpha=value/100))+
geom_polygon(data = map_data, aes(x=long, y=lat, group=group), fill="white")+
geom_path(data = ch_geom, aes(x=long, y=lat, group=group),color="grey80", size=.3)+
geom_polygon(data=seen_geom, aes(x=long, y=lat, group=group), fill="lightblue")+
geom_path(data=seen_geom, aes(x=long, y=lat, group=group), color="grey80", size=.3)+
geom_point(data=quakes0, aes(x=long, y=lat), color=col0, alpha=.5, size=0.4, pch=4)+
geom_point(data=quakes1, aes(x=long, y=lat), color=col1, alpha=.8, size=0.8)+
coord_equal()+
guides(alpha=FALSE)+
theme_bw()+
labs(y="", x="")+
theme(axis.text=element_blank(),
axis.ticks = element_blank(),
panel.grid = element_line(size=.2))+
ggsave(filename=paste0("relief_map_", i, ".pdf"), height=6, width=9.708)
#}
##############################################################################
# Packages
library(foreign)
library(maptools)
library(RColorBrewer)
library(Matching)
library(ebal)
library(xtable)
library(survey)
library(texreg)
library(rgdal)
library(dplyr)
library(ggplot2)
library(raster)
library(gpclib)
##############################################################################
##############################################################################
#
# Replication Code for Paper & Appendix
#
##############################################################################
##############################################################################
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Figure 1
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
gde_15 <- readOGR("geodata/", layer = "gde-1-1-15")
crs(gde_15) <- "+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs"
gde_15l <- readOGR(dsn="geodata", layer="VEC200_HOHEITSGEBIET_LV95")
gde_15l <- spTransform(gde_15l, CRS("+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs"))
ch <- gde_15l[gde_15l@data$ICC=="CH", ]
ch_geom <- fortify(ch, region="ICC")
seen_geom <- readRDS("geodata/seen_geom.Rds")
ch_geom <- readRDS("geodata/ch_geom.Rds")
# read in event data, coded as "quakes"
quakes <- foreign::read.dta("geodata/Disaster_events_dates_keeperL.dta")%>%
dplyr::select(J, K, keeperL)%>%
rename(long=J, lat=K)
quakes0 <- quakes[quakes$keeperL==0,1:2]
quakes1 <- quakes[quakes$keeperL==1,1:2]
map_data <- readRDS("geodata/map_data.Rds")
#read in relief ----
relief <- raster("geodata/02-relief-georef-clipped-resampled.tif")
relief_spdf <- as(relief, "SpatialPixelsDataFrame")
relief <- as.data.frame(relief_spdf) %>%
rename(value = `X02.relief.georef.clipped.resampled`)
# actual map
colls <- c("violetred4", "firebrick", "firebrick4", "violetred", "darkred", "darkmagenta", "darkorchid4", "blueviolet", "deeppink1")
col0 <- "white"
col1 <- "firebrick"
i <- 1
ggplot()+
geom_raster(data = relief, aes(x = x, y = y, alpha=value/100))+
geom_polygon(data = map_data, aes(x=long, y=lat, group=group), fill="white")+
geom_path(data = ch_geom, aes(x=long, y=lat, group=group),color="grey80", size=.3)+
geom_polygon(data=seen_geom, aes(x=long, y=lat, group=group), fill="lightblue")+
geom_path(data=seen_geom, aes(x=long, y=lat, group=group), color="grey80", size=.3)+
geom_point(data=quakes0, aes(x=long, y=lat), color=col0, alpha=.5, size=0.4, pch=4)+
geom_point(data=quakes1, aes(x=long, y=lat), color=col1, alpha=.8, size=0.8)+
coord_equal()+
guides(alpha=FALSE)+
theme_bw()+
labs(y="", x="")+
theme(axis.text=element_blank(),
axis.ticks = element_blank(),
panel.grid = element_line(size=.2))+
ggsave(filename="Relief_map.pdf", height=6, width=9.708)
data1 <- read.csv("pnl_leo_w4.csv")
data1 <- read.csv("Data/pnl_leo_w4.csv")
data1$cc.worry <- rep(NA,dim(data1)[1])
data1$Q16n <- factor(data1$Q16, levels=c("Gar nicht besorgt",
"Eher nicht besorgt",
"Eher besorgt",
"Sehr besorgt",
# "",
"Weiss nicht / keine Antwort"))
data1$Q2n <- factor(data1$Q2, levels=c("Gar nicht besorgt",
"Eher nicht besorgt",
"Eher besorgt",
"Sehr besorgt",
# "",
"Weiss nicht / keine Antwort"))
data1$cc.worry[is.na(data1$Q2n)] <- data1$Q16n[is.na(data1$Q2n)]
#data1$cc.worry[data1$Q16n==""] <- data1$Q2n[data1$Q16n==""]
data1$cc.worry[is.na(data1$Q16n)] <- data1$Q2n[is.na(data1$Q16n)]
par(mar=c(3,15,1,1), family="CMU Serif")
barplot(table(data1$Q4),horiz = TRUE, las=2,
names.arg = c("Deregulation of Construction Rules",
"Never wondered about this",
"No clear `reason`",
"Ineffective Bureaucracy",
"Climate Change",
"Don't know"),
col="dodgerblue3",
border=NA)
data1 <- read.csv("Data/pnl_leo_w4.csv")
data1$cc.worry <- rep(NA,dim(data1)[1])
data1$Q16n <- factor(data1$Q16, levels=c("Gar nicht besorgt",
"Eher nicht besorgt",
"Eher besorgt",
"Sehr besorgt",
"Weiss nicht / keine Antwort"))
data1$Q2n <- factor(data1$Q2, levels=c("Gar nicht besorgt",
"Eher nicht besorgt",
"Eher besorgt",
"Sehr besorgt",
"Weiss nicht / keine Antwort"))
data1$cc.worry[is.na(data1$Q2n)] <- data1$Q16n[is.na(data1$Q2n)]
data1$cc.worry[is.na(data1$Q16n)] <- data1$Q2n[is.na(data1$Q16n)]
data1 <- read.csv("Data/pnl_leo_w4.csv")
data1$cc.worry <- rep(NA,dim(data1)[1])
data1$Q16n <- factor(data1$Q16, levels=c("Gar nicht besorgt",
"Eher nicht besorgt",
"Eher besorgt",
"Sehr besorgt",
"Weiss nicht / keine Antwort"))
data1$Q2n <- factor(data1$Q2, levels=c("Gar nicht besorgt",
"Eher nicht besorgt",
"Eher besorgt",
"Sehr besorgt",
"Weiss nicht / keine Antwort"))
data1$cc.worry[is.na(data1$Q2n)] <- data1$Q16n[is.na(data1$Q2n)]
data1$cc.worry[is.na(data1$Q16n)] <- data1$Q2n[is.na(data1$Q16n)]
pdf("Surveyresponse.pdf",width=10,height=15)
par(mar=c(3,15,1,1), family="CMU Serif")
barplot(table(data1$Q4),horiz = TRUE, las=2,
names.arg = c("Deregulation of Construction Rules",
"Never wondered about this",
"No clear `reason`",
"Ineffective Bureaucracy",
"Climate Change",
"Don't know"),
col="dodgerblue3",
border=NA)
dev.off()
pdf("Surveyresponse.pdf",width=10,height=15)
par(mar=c(3,15,1,1))
barplot(table(data1$Q4),horiz = TRUE, las=2,
names.arg = c("Deregulation of Construction Rules",
"Never wondered about this",
"No clear `reason`",
"Ineffective Bureaucracy",
"Climate Change",
"Don't know"),
col="dodgerblue3",
border=NA)
dev.off()
library(rstan)
library(foreign)
library(reshape2)
library(plotrix)
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)
setwd("/Users/lleemann/Dropbox/Survey Research/Slides Term 2/7. IRT 2")
#setwd("/Users/lleemann/Documents/Academia/Uni Zürich/Lehre/2018 HS/Data Analysis/Session 3/Code and Data/")
data.ip<- read.dta("Data/Roll Call Parolen.dta")
head(data.ip)
names.v <- c("Vorlage","Legislatur", "Volk", "BR", "BV", "FDP", "CVP", "SP", "SVP", "CSP", "PdA", "Lega", "Economiesuisse", "SGB")
colnames(data.ip) <- names.v
data.ip <-data.ip[data.ip[,2]>43,]	# ab 44. Legislatur (1991)
data.ip <- data.ip[,-2]
data.ip$Vorlage1 <- 1:length(data.ip$Vorlage)
bill.info <- data.ip[,c(1,14)]
data.ip <- data.ip[,-1]
data.ip1 <- melt(data.ip, id.vars = c("Vorlage1"), variable.name = "Group")
data.ip1$Group1 <- as.numeric(as.factor(data.ip1$Group))
data.ip1 <- data.ip1[,-2]
nasCH <- which(is.na(data.ip1$value))
votesCH <- data.ip1$value[-nasCH]
N <- length(votesCH)
j <- data.ip1$Group1
j <- j[-nasCH]
k <- data.ip1$Vorlage1
k <- k[-nasCH]
J <- max(j)
K <- max(k)
Dim <- 2
CH_data <- list(N = N, K = K, J = J, j = j, k = k, y = votesCH, D=Dim, l1=6, l2=5,
b1=148, b2=36 , mu11=0, v11=.01, mu12= 2, v12=2,  mu21=-2, v21=2, mu22=4, v22=2)
# Vorlage 501: Volksinitiative Strom ohne Atom
# Vorlage 518* ist "Bundesgesetz uber die eingetragene Partnerschaft gleichgeschlechtlicher Paare (Partnerschaftsgesetz, PartG)" (2005)
# Vorlage 408 ist "Volksinitiative ´zum Schutze des Alpengebietes vor dem Transitverkehr" (1994)
start1 <- Sys.time()
stan.fit1 <- stan(file = "Code/Stan2d.stan",
data = CH_data, iter = 7000, warmup = 5000, chains = 4,
thin = 5, init = 'random', verbose = FALSE, cores = 4,
seed = 1234)
end1 <- Sys.time()
end1-start1 # 4.4 min on macbook 3.5 GHz Intel Core i7
library(rstan)
library(foreign)
library(reshape2)
library(plotrix)
options(mc.cores = parallel::detectCores())
rstan_options(auto_write = TRUE)
setwd("/Users/lleemann/Dropbox/Survey Research/Slides Term 2/IRT 2d")
#setwd("/Users/lleemann/Documents/Academia/Uni Zürich/Lehre/2018 HS/Data Analysis/Session 3/Code and Data/")
data.ip<- read.dta("Data/Roll Call Parolen.dta")
head(data.ip)
names.v <- c("Vorlage","Legislatur", "Volk", "BR", "BV", "FDP", "CVP", "SP", "SVP", "CSP", "PdA", "Lega", "Economiesuisse", "SGB")
colnames(data.ip) <- names.v
data.ip <-data.ip[data.ip[,2]>43,]	# ab 44. Legislatur (1991)
data.ip <- data.ip[,-2]
data.ip$Vorlage1 <- 1:length(data.ip$Vorlage)
bill.info <- data.ip[,c(1,14)]
data.ip <- data.ip[,-1]
data.ip1 <- melt(data.ip, id.vars = c("Vorlage1"), variable.name = "Group")
data.ip1$Group1 <- as.numeric(as.factor(data.ip1$Group))
data.ip1 <- data.ip1[,-2]
nasCH <- which(is.na(data.ip1$value))
votesCH <- data.ip1$value[-nasCH]
N <- length(votesCH)
j <- data.ip1$Group1
j <- j[-nasCH]
k <- data.ip1$Vorlage1
k <- k[-nasCH]
J <- max(j)
K <- max(k)
Dim <- 2
CH_data <- list(N = N, K = K, J = J, j = j, k = k, y = votesCH, D=Dim, l1=6, l2=5,
b1=148, b2=36 , mu11=0, v11=.01, mu12= 2, v12=2,  mu21=-2, v21=2, mu22=4, v22=2)
# Vorlage 501: Volksinitiative Strom ohne Atom
# Vorlage 518* ist "Bundesgesetz uber die eingetragene Partnerschaft gleichgeschlechtlicher Paare (Partnerschaftsgesetz, PartG)" (2005)
# Vorlage 408 ist "Volksinitiative ´zum Schutze des Alpengebietes vor dem Transitverkehr" (1994)
start1 <- Sys.time()
stan.fit1 <- stan(file = "Code/Stan2d.stan",
data = CH_data, iter = 7000, warmup = 5000, chains = 4,
thin = 5, init = 'random', verbose = FALSE, cores = 4,
seed = 1234)
end1 <- Sys.time()
end1-start1 # 4.4 min on macbook 3.5 GHz Intel Core i7
library(foreign)
library(foreign)
library(maptools)
library(RColorBrewer)
library(Matching)
library(ebal)
library(xtable)
library(survey)
library(texreg)
library(rgdal)
library(dplyr)
library(ggplot2)
library(raster)
library(gpclib)
help(foreign)
??foreign
??maptools
print(sessionInfo())
print(sessionInfo())
help(readOGR)
readOGR("", layer = "gde-1-1-15")
gde_15 <- readOGR("gde-1-1-15", layer = "gde-1-1-15")
gde_15 <- readOGR("geodata/", layer = "gde-1-1-15")
library(here)
gde_15 <- readOGR(here(), layer = "gde-1-1-15")
"gde-1-1-15"
here()
gde_15 <- readOGR(here(), layer = "b_gde-1-1-15")
gde_15 <- readOGR(layer = "b_gde-1-1-15")
gde_15 <- readOGR(here(),layer = "b_gde-1-1-15")
gde_15 <- readOGR(here(),layer = "b_gde-1-1-15")
gde_15 <- readOGR(layer = "b_gde-1-1-15")
gde_15 <- readOGR("geodata/", layer = "b_gde-1-1-15")
gde_15 <- readOGR("geodata/", layer = "b_gde-1-1-15")
gde_15 <- readOGR(layer = "gde-1-1-15")
gde_15 <- readOGR(here(), layer = "gde-1-1-15")
##############################################################################
##############################################################################
#
#				"Do Natural Disasters Help the Environment? How Voters
#         Respond and What That Means"
#
#       Leonardo Baccini and Lucas Leemann
#
#       Contact: leemann@ipz.uzh.ch
#
#       Version: March 2020
#
##############################################################################
##############################################################################
##############################################################################
# Packages
library(foreign)
library(maptools)
library(RColorBrewer)
library(Matching)
library(ebal)
library(xtable)
library(survey)
library(texreg)
library(rgdal)
library(dplyr)
library(ggplot2)
library(raster)
library(gpclib)
##############################################################################
##############################################################################
#
# Replication Code for Paper & Appendix
#
##############################################################################
##############################################################################
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Figure 1
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
gde_15 <- readOGR("geodata/", layer = "gde-1-1-15")
??readOGR
sample(c(1:6),1000,prob=c(1/6,1/6,1/3,1/6,1/6), replace=TRUE)
sample(c(1:5),1000,prob=c(1/6,1/6,1/3,1/6,1/6), replace=TRUE)
XX <- sample(c(1:5),1000,prob=c(1/6,1/6,1/3,1/6,1/6), replace=TRUE)
table(XX)
N <- 1000
catcher <- matrix(NA,5,N)
for (i in 1:N){
catcher[i,] <- table(sample(c(1:5),1000,prob=c(1/6,1/6,1/3,1/6,1/6), replace=TRUE))
}
N <- 1000
catcher <- matrix(NA,5,N)
for (i in 1:N){
catcher[i,] <- c(table(sample(c(1:5),1000,prob=c(1/6,1/6,1/3,1/6,1/6), replace=TRUE)))
}
N <- 1000
catcher <- matrix(NA,N,5)
for (i in 1:N){
catcher[i,] <- c(table(sample(c(1:5),1000,prob=c(1/6,1/6,1/3,1/6,1/6), replace=TRUE)))
}
catcher
quantile(catcher[,1], c(0.025,.5,.0975))
quantile(catcher[,1], c(0.025,.5,.975))
N <- 1000
catcher <- matrix(NA,N,5)
for (i in 1:N){
catcher[i,] <- c(table(sample(c(1:5),1428,prob=c(1/6,1/6,1/3,1/6,1/6), replace=TRUE)))
}
quantile(catcher[,1], c(0.025,.5,.975))/1428
set.seed(123)
N <- 1000
catcher <- matrix(NA,N,5)
for (i in 1:N){
catcher[i,] <- c(table(sample(c(1:5),1428,prob=c(1/6,1/6,1/3,1/6,1/6), replace=TRUE)))
}
quantile(catcher[,1], c(0.025,.5,.975))/1428
quantile(catcher[,2], c(0.025,.5,.975))/1428
set.seed(123)
N <- 1000
catcher <- matrix(NA,N,5)
for (i in 1:N){
catcher[i,] <- c(table(sample(c(1:5),1428,prob=c(1/6,1/6,1/3,1/6,1/6), replace=TRUE)))
}
quantile(catcher[,1], c(0.025,.5,.975))/1428
quantile(catcher[,2], c(0.025,.5,.975))/1428
quantile(catcher[,4], c(0.025,.5,.975))/1428
quantile(catcher[,5], c(0.025,.5,.975))/1428
library(foreign)
library(maptools)
library(RColorBrewer)
library(Matching)
library(ebal)
library(xtable)
library(survey)
library(texreg)
library(rgdal)
library(dplyr)
library(ggplot2)
library(raster)
library(gpclib)
data1 <- read.csv("Data/pnl_leo_w4.csv")
data1$cc.worry <- rep(NA,dim(data1)[1])
data1$Q16n <- factor(data1$Q16, levels=c("Gar nicht besorgt",
"Eher nicht besorgt",
"Eher besorgt",
"Sehr besorgt",
"Weiss nicht / keine Antwort"))
data1$Q2n <- factor(data1$Q2, levels=c("Gar nicht besorgt",
"Eher nicht besorgt",
"Eher besorgt",
"Sehr besorgt",
"Weiss nicht / keine Antwort"))
data1$cc.worry[is.na(data1$Q2n)] <- data1$Q16n[is.na(data1$Q2n)]
data1$cc.worry[is.na(data1$Q16n)] <- data1$Q2n[is.na(data1$Q16n)]
par(mar=c(3,15,1,1))
barplot(table(data1$Q4),horiz = TRUE, las=2,
names.arg = c("Deregulation of Construction Rules",
"Never wondered about this",
"No clear `reason`",
"Ineffective Bureaucracy",
"Climate Change",
"Don't know"),
col="dodgerblue3",
border=NA)
